package com.mutual.assistance.task.feignclient;

import com.mutual.assistance.response.R;
import com.mutual.assistance.task.config.OpenFeignConfig;
import com.mutual.assistance.task.model.dto.UserRemote;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * @author chenyuxin
 * @version 1.0
 * @description 远程调用用户服务
 * @date 2023/4/29 14:42
 */
@FeignClient(
        value = "user-api",
        url = "http://8.138.58.118:63010",
        fallbackFactory = UserServiceClientFallbackFactory.class,
        configuration = OpenFeignConfig.class
)
public interface UserServiceClient {

    @PutMapping(value = "/user/r/sub_credit")
    R<String> subCredit(@RequestParam("username") String username, @RequestParam("credit") Integer credit);

    @PutMapping("/user/r/rollback_credit")
    R<String> rollbackCredit(@RequestParam("username") String username, @RequestParam("credit") Integer credit);

    @GetMapping("/user/other/username")
    R<UserRemote> getPublishMessage(@RequestParam("username") String username);

    @PutMapping("/user/r/star")
    R<String> updateUserStar(@RequestParam("username") String username, @RequestParam("star") Integer star);
}
